package tianrun.ziguan.api.calculate.config.service.template.instance.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import tianrun.ziguan.api.calculate.config.dao.TStaticPropertiesInstanceMapper;
import tianrun.ziguan.api.calculate.config.dto.request.StaticPropertiesInstanceVO;
import tianrun.ziguan.api.calculate.config.entity.TStaticPropertiesInstance;
import tianrun.ziguan.api.calculate.config.service.template.instance.ITStaticPropertiesInstanceService;
import tianrun.ziguan.api.calculate.config.utils.CollectionUtil;

import java.util.Collections;
import java.util.List;
import java.util.Set;

@Service
public class TStaticPropertiesInstanceServiceImpl extends ServiceImpl<TStaticPropertiesInstanceMapper, TStaticPropertiesInstance> implements ITStaticPropertiesInstanceService {
    @Override
    public List<TStaticPropertiesInstance> listByModuleIds(Set<Long> ids) {
        if (CollectionUtil.isEmpty(ids)) {
            return Collections.emptyList();
        }
        return list(Wrappers.<TStaticPropertiesInstance>lambdaQuery().eq(TStaticPropertiesInstance::getIsValid, true).in(TStaticPropertiesInstance::getModuleId, ids));
    }

    @Override
    public List<StaticPropertiesInstanceVO> listVOByTemplateIds(Set<Long> ids) {
        if (CollectionUtil.isEmpty(ids)) {
            return Collections.emptyList();
        }
        return baseMapper.listByTemplateIds(ids);
    }
}
